
import mss
import pygetwindow as gw


with mss.mss() as sct:
    # 截取 DNF 窗口
    window = gw.getWindowsWithTitle('Dungeon & Fighter')[0]
    print(window)
    monitor = {
        "top": window.top,
        "left": window.left,
        "width": window.width,
        "height": window.height
    }

    sct_img = sct.grab(monitor)
    # screen = np.array(sct.grab(monitor))

    
output = "./tmp/sct-{top}x{left}_{width}x{height}.png".format(**monitor)
print(output)
mss.tools.to_png(sct_img.rgb, sct_img.size, output=output)